package cn.stylefeng.guns.modular.order.controller;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import cn.stylefeng.guns.modular.basic.entity.BasicWarehouse;
import cn.stylefeng.guns.modular.basic.model.params.BasicWarehouseParam;
import cn.stylefeng.guns.modular.basic.model.result.BasicWarehouseResult;
import cn.stylefeng.guns.modular.basic.service.BasicWarehouseService;
import cn.stylefeng.guns.modular.order.model.params.OrderTransportParam;
import cn.stylefeng.guns.modular.order.model.result.OrderTransportResult;
import cn.stylefeng.guns.modular.order.service.OrderTransportService;

/**
 * 发运量热力图
 */
@Controller
@RequestMapping("/dataPro")
public class dataProController {
    
    @Autowired
    private OrderTransportService orderTransportService;

    @Autowired
    private BasicWarehouseService basicWarehouseService;

    /**
     * 查询仓库list
     * @param
     * @return
     */
    @ResponseBody
    @RequestMapping("/getWarehouselist")
    public List<BasicWarehouseResult> getWarehouselist() {
        BasicWarehouseParam basicWarehouseParam = new BasicWarehouseParam();
        basicWarehouseParam.setWarehouseTypes("零售");
        List<BasicWarehouseResult> list = basicWarehouseService.findListBySpec(basicWarehouseParam ,null,null);
        return list;
    }

    /**
     * 货运订单汇总
     */
    @ResponseBody
    @RequestMapping("/orderTransportCount")
    public List<OrderTransportResult> orderTransportCount(Long[] wids ,String month) {
    	OrderTransportParam orderTransportParam = new OrderTransportParam();
        List<Long> oids = new ArrayList<Long>();
    	for (Long wid : wids) {
    		BasicWarehouse basicWarehouse = basicWarehouseService.getById(wid);
    		if(basicWarehouse != null) {
                oids.add(Long.parseLong(basicWarehouse.getWarehouseOperateId() + ""));
//    			orderTransportParam.setOids(Collections.singletonList(Long.parseLong(basicWarehouse.getWarehouseOperateId() + "")));
    		}
		}
        orderTransportParam.setOids(oids);
        return this.orderTransportService.findOrderTransportCountDataBySpec(orderTransportParam,month);
    }
    
    
    
    

}
